<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('借款单')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
<div class="navigation visible-xs-block">
    <ol class="breadcrumb">
        <span> > </span>
        <li><a href="#" onclick="gomain()">主页</a></li>
        <li style="color: black">借款单</li>
    </ol>
    <div class="aLine"></div>
</div>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>借款类型：</label>
<!--                                <select name="bStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
                                <select id="bStatus" name="bStatus" th:with="type=${@dict.getType('borrowing_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}">
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">借款申请人：</label>
                                <input type="text" name="bApplicant"/>
                            </li>
                            <li class="select-time">
                                <label>借款时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginBTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endBTime]"/>
                            </li>
                            <li>
                                <label>借款原因：</label>
                                <input type="text" name="bCause"/>
                            </li>
                            <li>
                                <label>借款金额：</label>
                                <input type="text" name="bAmount"/>
                            </li>
                            <li>
                                <label>余额：</label>
                                <input type="text" name="bBalance"/>
                            </li>
                            <li hidden>
                                <label>审批类型：</label>
                                <select name="bType" th:with="type=${@dict.getType('')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px">审批意见：</label>
                                <input type="text" name="bOpinion"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="btn-group-sm" id="toolbar" role="group" style="line-height:10px">
                <div style="display: inline-block; margin-right: 10px;">
                    <div class="panel panel-info">
                        <div class="panel-heading">
                            余额：
                        </div>
                        <div class="panel-body">
                            <h3 style="display: inline-block;">￥</h3>
                            <input type="text" disabled="disabled" style="border:none; background: white; font-size: 20px; color: black; display: inline-block" value="0"/>
                        </div>
                    </div>
                </div>
                <div style="display: inline-block;">
                    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="ruoyi:amount:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="ruoyi:amount:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="ruoyi:amount:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="ruoyi:amount:export">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:amount:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:amount:remove')}]];
        var prefix = ctx + "ruoyi/amount";
        var bStatus = [[${@dict.getType('borrowing_status')}]];
        var bType = [[${@dict.getType('borrowing_type')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showColumns: false,
                modalName: "借款列表",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'bId', 
                    title: '借款id',
                    visible: false
                },
                {
                    field: 'bStatus', 
                    title: '借款类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(bStatus, value);
                    }
                },
                {
                    field: 'bApplicant', 
                    title: '借款申请人'
                },
                {
                    field: 'bTime',
                    title: '借款时间'
                },
                {
                    field: 'bCause', 
                    title: '借款原因'
                },
                {
                    field: 'bAmount', 
                    title: '借款金额'
                },
                // {
                //     field: 'bBalance',
                //     title: '余额'
                // },
                {
                    field: 'bType',
                    title: '审批类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(bType, value);
                    }
                },
                {
                    field: 'bOpinion',
                    title: '审批意见'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.bType==0){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.bId+ '\')"><i class="fa fa-user"></i> 提交</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }else if (row.bType ==1){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="revocations(\'' + row.bId + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                        }else if (row.bType ==2){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="revocations(\'' + row.bId + '\')"><i class="fa fa-user"></i> 撤销</a> ');
                        }else if (row.bType ==5){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="over(\'' + row.bId + '\')"><i class="fa fa-user"></i> 结束</a> ');
                        }else if(row.bType ==4){
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="submitApply(\'' + row.bId + '\')"><i class="fa fa-user"></i> 重新提交</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.bId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.bId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function submitApply(bId) {
            $.modal.confirm("确认要提交申请吗?", function() {
                var url = prefix + "/submitApply";
                var data = { "bId": bId};
                $.operate.submit(url, "post", "json", data);
            });
        }
        function over(bId) {

            $.modal.confirm("确认要结束流程吗?", function() {
                var url = prefix + "/over";
                var data = { "bId": bId };
                $.operate.submit(url, "post", "json", data);
            });
        }
        function revocations(bId) {
            $.modal.confirm("确认要撤销申请吗?", function () {
                var url = prefix + "/revocations";
                var data = {"bId": bId};
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>
</html>